package com.axc.gallery2.edit.effective;

import android.graphics.Bitmap;
import android.graphics.Matrix;

public class ToZoomImage {
	// 图片的放大缩小
	float scalewidth = 0f;
	float scalheight = 0f;

	public Bitmap ProcessImage(Bitmap bitmap, int w, int h) {

		int width = bitmap.getWidth();
		int height = bitmap.getHeight();
		Matrix matrix = new Matrix();
		if (width > w && height > h) {
			scalewidth = ((float) w / width);
			scalheight = ((float) h / height);
		} else {
			scalewidth = (1 + (width / (float) w));
			scalheight = (1 + (height / (float) h));
		}
		matrix.postScale(scalewidth, scalheight);// 對圖片進行縮放處理
		// 获取处理后的图片再返回
		Bitmap newbitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height,
				matrix, true);
		return newbitmap;
	}
}
